use crate::db::dao::im_setting_dao::{setting_insert, setting_query_by_name, setting_update};
use crate::db::db::Db;
use crate::db::pojo::pojo::ImSetting;

pub struct ImSettingService;

impl ImSettingService {
    pub(crate) fn get_by_name(&self, current_user_id: &String, name: &'static str) -> Option<ImSetting> {
        let db = Db::open();
        setting_query_by_name(db.clone(), current_user_id, name)
    }

    pub(crate) fn insert(&self, mut setting: &mut ImSetting) {
        let db = Db::open();

        setting_insert(db.clone(), &mut setting);
    }

    pub(crate) fn update(&self, mut setting: &mut ImSetting) {
        let db = Db::open();
        setting_update(db.clone(), &mut setting);
    }
}
